package com.application.magazine;

import java.util.List;
import com.roscopeco.ormdroid.Entity;

public class Magazine extends Entity {
	public int id;
	public String title;
	public String path;
	public Category cat;
	public String status;
	public String tumbnail;
	public String iss;
	public String read;
	

	public Magazine() {
		this(null, null, null, null, null, null, null);
	}

	public Magazine(String title, String path, Category cat, String status, String tumbnail, String iss, String read) {
		this.title = title;
		this.cat = cat;
		this.path = path;
		this.status = status;
		this.tumbnail = tumbnail;
		this.iss = iss;
		this.read = read;
	}

	public List<Bookmarks> bookmarks() {
		return query(Bookmarks.class).where("magazine").eq(id).executeMulti();
	}
	
	public List<Images> images() {
		return query(Images.class).where("magazine").eq(id).executeMulti();
	}

	public void removeAll() {
		List<Magazine> list = query(Magazine.class).executeMulti();
		for (Magazine mag : list) {
			mag.delete();
		}
	}
	public int getPk(){
		List<Magazine> list = null;
		int key = 1;
		list = query(Magazine.class).executeMulti();
		if(list!=null && !list.isEmpty()){
			key = list.size()+1;
		}
		return key;
		
	}
}
